<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    .img-container {
        position: relative;
        padding-bottom: 48%;
        height: 0;
        overflow: hidden;
        background: red;
    }
    .img-container img {
        position: absolute;
        top: 0; left: 0;
        width: 100%; height: 100%;
    }</style>
</head>
<body>
    <div class="img-container">
        <img src="img.jpg" alt="" />
    </div>
</body>
</html>